// 生成router_autojs模板
module.exports = {
  jsTemplate: (components, homePage) => {
    let importStr = ``
    let rStr = ``
    let homeStr = ``
    for (item of components) {
      importStr += `
import ` + item.name + ` from '` + item.impPath + `'`
      if (homePage == item.name) {
        homeStr = `
      {
        path : '/',
        name : '/',
        component : `+ item.name + `,
      },`
      } else {
        rStr += `
      {
        path : '`+ item.r_path + `',
        name : '`+ item.name + `',
        component : `+ item.name + `,
      },`
      }
    }
    //注意处理旧有router
    return `
import Vue from 'vue'
import Router from 'vue-router'`+ importStr + `
//_@import_end
Vue.use(Router)

export default new Router({
  routes: [
      `+ homeStr + rStr + `
//_@router_end
    ]
  })
`
  }
}
